﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Gnosis.Alexandria.Model
{
    public class Country
        : NamedHashedCodedBase, ICountry
    {
        public Country()
        {
        }

        public override string RecordName
        {
            get { return "Country"; }
        }

        public static void InitializeCache(IEnumerable<ICountry> countries)
        {
            foreach (ICountry country in countries)
                _all.Add(country.Id, country);
        }

        public static bool IsInitialized { get { return _all.Count > 0; } }

        private static readonly IDictionary<long, ICountry> _all = new Dictionary<long, ICountry>();

        public static ICountry GetById(long id)
        {
            return (_all.ContainsKey(id)) ? _all[id] : null;
        }

        public static ICollection<ICountry> All()
        {
            return _all.Values;
        }
    }
}
